using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using log4net;
using Newtonsoft.Json;
using Triton.Bot.Settings;
using Triton.Common;
using Triton.Game.Mapping;
using Logger1 = Triton.Common.LogUtilities.Logger;

namespace Monitor
{
    /// <summary>Settings for the Stats plugin. </summary>
    public class MonitorSettings : JsonSettings
    {
        private static readonly ILog Log = Logger1.GetLoggerInstanceForType();

        private static MonitorSettings _instance;

        /// <summary>The current instance for this class. </summary>
        public static MonitorSettings Instance
        {
            get { return _instance ?? (_instance = new MonitorSettings()); }
        }

        /// <summary>The default ctor. Will use the settings path "Stats".</summary>
        public MonitorSettings()
            : base(GetSettingsFilePath(Configuration.Instance.Name, string.Format("{0}.json", "Stats")))
        {
        }

        private int _wins;
        private int _losses;
        private int _concedes;
        private int _level;
        private int _xp;
        private int _xpNeeded;

        /// <summary>Current stored wins.</summary>
        [DefaultValue(0)]
        public int Wins
        {
            get { return _wins; }
            set
            {
                if (value.Equals(_wins))
                {
                    return;
                }
                _wins = value;
                NotifyPropertyChanged(() => Wins);
            }
        }

        /// <summary>Current stored losses.</summary>
        [DefaultValue(0)]
        public int Losses
        {
            get { return _losses; }
            set
            {
                if (value.Equals(_losses))
                {
                    return;
                }
                _losses = value;
                NotifyPropertyChanged(() => Losses);
            }
        }

        /// <summary>Current stored concedes.</summary>
        [DefaultValue(0)]
        public int Concedes
        {
            get { return _concedes; }
            set
            {
                if (value.Equals(_concedes))
                {
                    return;
                }
                _concedes = value;
                NotifyPropertyChanged(() => Concedes);
            }
        }

        [DefaultValue(0)]
        public int Level
        {
            get { return _level; }
            set
            {
                if (value.Equals(_level))
                {
                    return;
                }
                _level = value;
                NotifyPropertyChanged(() => Level);
            }
        }

        [DefaultValue(0)]
        public int Xp
        {
            get { return _xp; }
            set
            {
                if (value.Equals(_xp))
                {
                    return;
                }
                _xp = value;
                NotifyPropertyChanged(() => Xp);
            }
        }

        [DefaultValue(0)]
        public int XpNeeded
        {
            get { return _xpNeeded; }
            set
            {
                if (value.Equals(_xpNeeded))
                {
                    return;
                }
                _xpNeeded = value;
                NotifyPropertyChanged(() => XpNeeded);
            }
        }
    }
}
